package GUIs;
import java.awt.GridLayout;
import java.awt.event.ActionListener;

import javax.swing.*;

public class UpdatePanel extends JPanel {
	private JTextField alter_text;
	private JButton alter_button;
	/**
	 * Constructor to create an object  of UpdatePanel and initial a set of valriable
	 */
	public UpdatePanel(){
		
		this.setLayout(new GridLayout(3,1));
		alter_text = new JTextField("");
		alter_text.setSize(80, 70);
		this.add(new JLabel("Please insert new time :"));
		this.add(alter_text);
		
		alter_button = new JButton(" Update ");
		this.add(alter_button);
	}
	/**
	 * Method to get new Button of "Alter"
	 * @return new Button of "Alter"
	 */
	public JButton getAlterButton(){
		return alter_button;
	}
	/**
	 * Method to get new speed or gap time of Threads
	 * @return the gap-time of Threads
	 */
	public int getTime(){
		try{
			int time = Integer.parseInt(alter_text.getText());
			return time;	
		}
		catch(NumberFormatException nfe){
			 JOptionPane.showMessageDialog( null,"The speed value is wrong!!");
			 alter_text.setText("");
			 return 1000;	
		}		
	}
}
